home *** CD-ROM | disk | FTP | other *** search
- /* gpiomeas.c
- This program does the following:
- - Creates a GPIO session with timeout and error checking
- - Signals the device with a CTL0 pulse
- - Reads the device's response using formatted I/O
- */
-
- #include <stdio.h>
- #include <sicl.h>
-
- main()
- {
- INST id; /* interface session id */
- float result; /* data from device */
-
- #if defined (__BORLANDC__) && !defined (__WIN32__)
- _InitEasyWin(); /* required for Borland EasyWin programs */
- #endif
-
- /* log message and exit program on error */
- ionerror(I_ERROR_EXIT);
-
- /* open GPIO interface session, with 3-second timeout */
- id = iopen("gpio");
- itimeout(id, 3000);
-
- /* setup formatted I/O configuration */
- igpiosetwidth(id, 8);
- igpioctrl(id, I_GPIO_READ_EOI, '\n');
-
- /* monitor the device's PSTS line */
- igpioctrl(id, I_GPIO_CHK_PSTS, 1);
-
- /* signal the device to take a measurement */
- itrigger(id);
-
- /* get the data */
- iscanf(id, "%f%*t", &result);
- printf("Result = %f\n", result);
-
- /* close session */
- iclose (id);
-
- /* For Windows 3.1, call _siclcleanup before exiting to release
- resources allocated by SICL for this application. This call
- is a no-op for WIN32 applications.
- */
- _siclcleanup();
-
- return 0;
- }
-